package com.example.pjy.mapper;

import com.example.pjy.pojo.Academic;
import com.example.pjy.pojo.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface AcademicMapper {
//    void insert(Academic academic);
//    void deleteById(int id);
//    void update(Academic academic);
//    List<Academic> selectAll();
//    Academic selectById(int student_id);

    //新增
    @Insert("insert into academic (studentId,totalScore,count,score)" +
            "values(#{studentId},#{totalScore},#{count},#{totalScore}/#{count})")
    void add(Academic academic);



    //查询所有
    @Select("select * from academic")
    List<Academic> list();


    //根据id查询
    @Select("select * from academic where studentId = #{studentId}")
    Academic findById(Integer studentId);




    //更新
    @Update("update academic set studentId=#{studentId},totalScore=#{totalScore},count=#{count},score=#{totalScore}/#{count} where studentId=#{studentId}")
    void updateac(Academic academic);




    //删除
    @Delete("delete from academic where studentId=#{studentId}")
    void delete(Integer studentId);


    //查询是否有相同学号
    @Select("select count(*)>0 from academic where studentId = #{studentId}")
    boolean isExist(Integer studentId);

}
